import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;


public class CreateDataTest {
	private int numberOfMovies;
	private int numberOfShow;
	public CreateDataTest()
	{
	}
	public void readCinema()
	{
		try (BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Desktop\\DataTest\\Cineplex.txt")))
		{
			String currentLine;
			int i=0;
			currentLine = br.readLine();
			while (currentLine!=null)
			{
				CineplexItem temp= new CineplexItem();
				MovieApp.cineplexList.add(temp);
				MovieApp.cineplexList.get(i).setCineplexName(currentLine);
				currentLine = br.readLine();
				i++;
			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
		
	}
	public void readMovies()
	{
		try (BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Desktop\\DataTest\\Movies.txt")))
		{
			String currentLine;
			int numberOfMovie=Integer.parseInt(br.readLine());
			this.numberOfMovies=numberOfMovie;
			for (int i=0;i<numberOfMovie;i++)
			{
				currentLine = br.readLine();
				MovieItem temp = new MovieItem();
				MovieApp.movieList.add(temp);
				MovieApp.movieList.get(i).setMovieName(currentLine);
				currentLine = br.readLine();
				MovieApp.movieList.get(i).setMovieType(currentLine);
				currentLine = br.readLine();
				for (int j=0;j< MovieApp.movieClass.length;j++)
					if (currentLine.trim().toLowerCase().equals(MovieApp.movieClass[j].trim().toLowerCase()))
					{
						MovieApp.movieList.get(i).setMovieClass(j);
						break;
					}
				currentLine = br.readLine();
				for (int j=0;j< MovieApp.movieStatus.length;j++)
					if (currentLine.trim().toLowerCase().equals(MovieApp.movieStatus[j].trim().toLowerCase()))
					{
						MovieApp.movieList.get(i).setMovieStatus(j);
						break;
					}
				
				
			}	
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
	}
	
	public void readShow()
	{
		try (BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Desktop\\DataTest\\Shows.txt")))
		{
			String currentLine;
			int numberOfShow=Integer.parseInt(br.readLine());
			this.numberOfShow=numberOfShow;
			for (int i =0; i<numberOfShow;i++)
			{
				currentLine = br.readLine();
				ShowItem temp = new ShowItem();
				temp.setMovieName(currentLine);
				currentLine = br.readLine();
				temp.setCineplex(currentLine);
				currentLine = br.readLine();
				temp.setTime(currentLine);
				currentLine = br.readLine();
				CinemaItem cinemaItem= new CinemaItem();
				cinemaItem.setCinemaName(currentLine);
				temp.setCinemaItem(cinemaItem);
				currentLine = br.readLine();
				for (int j=0;j< MovieApp.movieStatus.length;j++)
					if (currentLine.trim().toLowerCase().equals(MovieApp.cinemaClass[j].trim().toLowerCase()))
					{
						temp.setCinemaClass(j);
						break;
					}
				for (int j = 0; j<MovieApp.cineplexList.size();j++)
				{
					if (MovieApp.cineplexList.get(j).getCineplexName().trim().toLowerCase().equals(temp.getCineplex().trim().toLowerCase()))
						MovieApp.cineplexList.get(j).getShowList().add(temp);
				}
				for (int j=0; j<MovieApp.movieList.size();j++)
					if( MovieApp.movieList.get(j).getMovieName().trim().toLowerCase().equals(temp.getMovie().getMovieName().trim().toLowerCase()))
						MovieApp.movieList.get(j).getShowListOfMovie().add(temp);
				
			}
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		
	}
	
	
	public void readStaff()
	{
		try (BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\DELL\\Desktop\\DataTest\\Staff.txt")))
		{
			String currentLine;
			int numberOfStaff=Integer.parseInt(br.readLine());
			for (int i=0;i<numberOfStaff;i++)
			{
				currentLine = br.readLine();
				StaffItem temp = new StaffItem();
				temp.setStaffAccount(currentLine);
				currentLine = br.readLine();
				temp.setStaffPassWord(currentLine);
				MovieApp.staffList.add(temp);
			}
		}catch (IOException e)
			{
				e.printStackTrace();
			}
			
			
	}
	public int getNumberOfMovies()
	{
		return numberOfMovies;
	}
	
	public int getNumberOfShow()
	{
		return numberOfShow;
	}
	
}
